package com.cqcomponents.components;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cqcomponents.api.components.IComponent;

public abstract class BaseComponent implements IComponent {
	private long startTime;
	private long renderTime;
	protected Logger logger = LoggerFactory.getLogger(this.getClass());
	private String resourcePath;
	private String pagePath;
	private String currentPagePath;

	public final void beforeComponentRender() {
		this.startTime = System.currentTimeMillis();
		this.onBeforeComponentRender();
	}

	protected void onBeforeComponentRender() {

	}

	public void setResourcePath(String resourcePath) {
		this.resourcePath = resourcePath;
	}

	public void setPagePath(String pagePath) {
		this.pagePath = pagePath;
	}

	public void setCurrentPagePath(String currentPagePath) {
		this.currentPagePath = currentPagePath;
	}

	public String getCurrentPagePath() {
		return currentPagePath;
	}

	public String getPagePath() {
		return pagePath;
	}

	public String getResourcePath() {
		return resourcePath;
	}

	public final void afterComponentRender() {
		renderTime = System.currentTimeMillis() - startTime;
		this.onAfterComponentRender();
	}

	protected void onAfterComponentRender() {

	}

	public final long getRenderTime() {
		return renderTime;
	}
}
